{extend name='main'}

{block name="button"}

{if auth('store/index')}
<!--<button class='layui-btn layui-btn-sm layui-btn-primary' data-open="{:url('store/index')}">插件市场</button>-->
{/if}

{if auth('login/in')}

{if $login.code eq 'done'}

{notempty name='login.user.extra.vips_total'}
<span class="layui-btn layui-btn-sm layui-btn-primary">VIP{$login.user.extra.vips_total|default=0}</span>
{else}
<span class="layui-btn layui-btn-sm layui-btn-primary">普通用户</span>
{/notempty}

<button class='layui-btn layui-btn-sm layui-btn-primary' data-href="https://center.plugin.thinkadmin.top">{$login.user.email|default='Undefind Email'}</button>
<button class='layui-btn layui-btn-sm layui-btn-danger' data-confirm="确认要退出登录吗？" data-load="{:url('login/logout')}">退出</button>

{elseif $login.code eq 'temp'}
<span class="layui-btn layui-btn-sm layui-btn-primary" data-width="400px" data-title="绑定邮箱 ( 测试中 )" data-modal="{:url('login/in')}">临时用户</span>
<button class='layui-btn layui-btn-sm layui-btn-primary' data-width="400px" data-title="绑定邮箱 ( 测试中 )" data-modal="{:url('login/in')}">{$login.user.nickname|default='Undefind Nickname'}</button>
<button class='layui-btn layui-btn-sm layui-btn-danger' data-confirm="确认要退出登录吗？" data-load="{:url('login/logout')}">退出</button>
{else}
<button class='layui-btn layui-btn-sm layui-btn-primary' data-width="400px" data-title="用户登录 ( 测试中 )" data-modal="{:url('login/in')}">用户登录</button>
{/if}

{/if}

{/block}

{block name='content'}
<style>

    .layui-card-html {
        min-height: 100%;
    }

    .plugin-item {
    }

    .plugin-item:hover .uploadimage {
        background-position: 0 0 !important;
    }

    .plugin-item-icon {
        width: 100%;
        padding-top: 30%;
        margin-bottom: 0;
    }

    .plugin-item-name {
        left: 0;
        right: 0;
        color: #fff;
        bottom: 0;
        padding: 0.8em 0;
        position: absolute;
        text-align: center;
        background-color: rgba(0, 0, 0, 0.6);
    }

    .plugin-item-tags {
        top: 0;
        left: 0;
        right: 0;
        padding: 3px 5px;
        position: absolute;
    }

    .plugin-item-tags .layui-badge {
        box-shadow: 1px 1px 2px 0 rgba(50, 50, 54, 0.5);
    }
</style>

<script>
    $(function () {
        $('body').off('click', '[data-plugs-click]').on('click', '[data-plugs-click]', function () {
            $('#p' + (this.dataset.plugsClick || 'plugin-encode')).trigger('click');
        })
    })
</script>

<div class="layui-tab layui-tab-card absolute" style="top:0;left:0;right:0;bottom:0;background:#fff">
    <ul class="layui-tab-title relative" style="z-index: 2">
        {foreach $types as $k=>$v}{if isset($total[$k])}{if isset($type) and $type eq $k}
        <li data-open="{:url('index')}?type={$k}&from={$get.from|default=''}" class="layui-this">{$v} <span class="font-s10 color-blue">x{$total[$k]}</span></li>
        {else}
        <li data-open="{:url('index')}?type={$k}&from={$get.from|default=''}">{$v} <span class="font-s10 color-blue">x{$total[$k]}</span></li>
        {/if}{/if}{/foreach}
    </ul>
    <div class="layui-tab-content absolute overauto" style="top:40px;left:0;right:0;bottom:0;padding:30px;z-index:1">
        <div class="layui-row layui-col-space30">
            {foreach $items as $item}
            <div class="layui-col-xs12 layui-col-sm6 layui-col-md4 layui-col-lg3">
                <div class="plugin-item">
                    <div class="plugin-item-icon uploadimage" data-lazy-src="{$item.cover|default=''}" data-plugs-click="{$item.encode}">
                        <div class="plugin-item-tags">
                            <div class="layui-badge layui-bg-cyan pull-left" style="margin-top:3px" data-tips-text="插件应用名称">{$item.code|default=''}</div>
                            {if $item.license eq 'vips'}
                            <span class="layui-badge think-bg-violet">会员免费</span>
                            {elseif $item.license eq 'free'}
                            <span class="layui-badge layui-bg-green layui-hide">免费使用</span>
                            {elseif $item.amount>0}
                            <span class="layui-badge layui-bg-blue">￥{$item.amount|default='0.00'}</span>
                            {else}
                            <span class="layui-badge layui-bg-green">推广免费</span>
                            {/if}
                            {notempty name='item.version'}
                            <div class="layui-badge think-bg-violet pull-right" style="margin-top:3px" data-tips-text="当前安装版本">{$item.version|default=''}</div>
                            {/notempty}
                        </div>
                        <div class="plugin-item-name">
                            <div class="layui-elip">{$item.name}</div>
                        </div>
                    </div>
                </div>
                <div class="margin-top-10">
                    {notempty name='item.plugmenus'}
                    <a class="layui-btn layui-btn-sm" id="p{$item.encode}" data-href="{$item.center}">管理插件</a>
                    {if auth('setdefault') and isset($default) and $default eq $item.code}
                    <a class="layui-btn layui-btn-sm layui-btn-normal pull-right" data-action="{:url('setdefault')}" data-value="default#0">取消默认</a>
                    {elseif auth('setdefault')}
                    <a class="layui-btn layui-btn-sm layui-btn-primary pull-right" data-action="{:url('setdefault')}" data-value="default#{$item.code}">设为默认</a>
                    {/if}
                    {else}
                    <a class="layui-btn layui-btn-sm layui-btn-disabled">管理插件</a>
                    {/notempty}
                </div>
            </div>
            {/foreach}
            {empty name='items'}
            <div>
                <div class="notdata">无记录</div>
            </div>
            {/empty}
        </div>
    </div>
</div>
{/block}